package com.gxa.clientarticle.service.impl;

/*
 *
 *@author leijun
 *
 *@creating 2020/11/13 14:18
 *
 */

import com.gxa.clientarticle.mapper.TypeTableMapper;
import com.gxa.clientarticle.pojo.TypeTable;
import com.gxa.clientarticle.service.TypeTableService;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName TypeServiceImpl
 * @Description TODO
 * @Author 俊
 * @Date 2020/11/13 14:18
 * @Version 1.0
 */
@Service("typeTableService")
public class TypeTableServiceImpl implements TypeTableService {

    @Resource
    TypeTableMapper typeTableMapper;

    @Override
    public Integer add(TypeTable typeTable) {
        return typeTableMapper.insertSelective(typeTable);
    }

    @Override
    public Integer update(TypeTable typeTable) {
        Example example = new Example(TypeTable.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("id",typeTable.getId());
        return typeTableMapper.updateByExampleSelective(typeTable,example);
    }

    @Override
    public Map list() {
        HashMap<String, Object> map = new HashMap<>();
        List<TypeTable> tables = typeTableMapper.selectAll();
        map.put("list",tables.toArray());
        return map;
    }
}
